//
// Created by francklinson on 2021/7/24 AT 23:15.
//
#include <vector>
#include <string>
#include <iostream>

using namespace std;

class Solution {
public:
    string largestOddNumber(string num) {
        int n = num.size();
        for (int i = n - 1; i >= 0; --i) {
            if ((num[i] - '0') % 2 == 1) {
                // 找到第一个值为奇数的字符，返回 num[0:i+1]
                return num.substr(0, i + 1);
            }
        }
        // 未找到值为奇数的字符，返回空字符串
        return "";
    }
};

int main() {
    Solution solution;
    cout << solution.largestOddNumber("523") << endl;
    cout << solution.largestOddNumber("52") << endl;
    cout << solution.largestOddNumber("5217") << endl;
    cout << solution.largestOddNumber("4") << endl;
    cout << solution.largestOddNumber("4206") << endl;
    return 0;
}

